﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace MyChart
{
    /// <summary>
    /// 控件的数据项序列
    /// </summary>
    public class ChartSeries
    {
        #region 字段

        private ChartItemCollection _items = new ChartItemCollection();
        private string _name = "";
        private Color _color = new Color();
        private bool _showValues = true;
        private bool _showAnchors = true;
        private bool _isDashed = false;
        private SeriesRenderType _renderType = SeriesRenderType.Line;
        private YAxis _parentYAxis;

        #endregion

        #region 属性

        /// <summary>
        /// 获取当前序列所包含的数据项集合
        /// </summary>
        public ChartItemCollection Items
        {
            get { return _items; }
        }

        /// <summary>
        /// 获取或设置序列展现时的名称文本
        /// </summary>
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        /// <summary>
        /// 获取或设置序列展现时的图形颜色
        /// </summary>
        public Color Color
        {
            get { return _color; }
            set { _color = value; }
        }

        /// <summary>
        /// 获取或设置一个值，表示是否显示当前序列数据项的值
        /// </summary>
        public bool ShowValues
        {
            get { return _showValues; }
            set { _showValues = value; }
        }

        /// <summary>
        /// 获取或设置一个值，表示是否显示当前序列数据项值对应的坐标点
        /// </summary>
        public bool ShowAnchors
        {
            get { return _showAnchors; }
            set { _showAnchors = value; }
        }

        /// <summary>
        /// 获取或设置一个值，表示是否显示当前序列是否以虚线形式展现
        /// </summary>
        public bool IsDashed
        {
            get { return _isDashed; }
            set { _isDashed = value; }
        }

        /// <summary>
        /// 获取或设置一个值，表示是否显示当前序列的展现图形类型
        /// </summary>
        public SeriesRenderType RenderType
        {
            get { return _renderType; }
            set { _renderType = value; }
        }

        /// <summary>
        /// 获取或设置当前序列属于所对应的Y坐标轴
        /// </summary>
        public YAxis ParentYAxis
        {
            get { return _parentYAxis; }
            set { _parentYAxis = value; }
        }
        /// <summary>
        /// 实现不同的序列的鼠标提示不同
        /// </summary>
        public string ToolTextFormat { get; set; }
        /// <summary>
        /// 支持不同序列实现的点击事件不同
        /// </summary>
        public string OnClientClick { get; set; }
        #endregion
        #region 方法

        /// <summary>
        /// 改变本序列中所有记录对应的值字段
        /// </summary>
        /// <param name="fieldName">新值字段名</param>
        public void ChangeDataValueField(string fieldName)
        {
            foreach (ChartItem item in _items)
            {
                if (item.Row != null)
                {
                    item.Value = item.Row[fieldName].ToString();
                }
            }
        }

        #endregion
    }
}
